'''
/*
 * @Author: wevsmy 
 * @Date: 2017-10-26 11:28:24 
 * @Last Modified by: wevsmy
 * @Last Modified time: 2017-10-26 11:48:03
 */
'''
import socket,sys

dest = ("<broadcast>",7788)

udpSocket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
udpSocket.bind(("",6767))
# 对这个需要发送广播数据的套接字进行修改设置，否则不能发送广播数据
udpSocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)

udpSocket.sendto("hi".encode("utf-8"),dest)

print("dengdai")
while True:
    (buf,adder) = udpSocket.recvfrom(1024)
    print("%s:%s"%(adder,buf))